home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Online / httpproxy / src / debug.h < prev    next >
C/C++ Source or Header  |  1996-08-20  |  3KB  |  99 lines

  1. /*(( "Header" */
  2. /*
  3.  * $Id: debug.h,v 1.2 1996/08/20 17:36:43 mshopf Exp mshopf $
  4.  *
  5.  * (c) 1995-96 Matthias Hopf
  6.  *
  7.  * Debugging macros.
  8.  *
  9.  */
  10.  
  11. /*
  12.  * $Log: debug.h,v $
  13.  * Revision 1.2  1996/08/20  17:36:43  mshopf
  14.  * added DEBUG_LEVELS description macro.
  15.  *
  16.  * Revision 1.1  1996/08/11  22:25:15  mshopf
  17.  * Initial revision
  18.  *
  19.  *
  20.  */
  21.  
  22. /*)) */
  23.  
  24. #ifndef _DEBUG_H__
  25. #define _DEBUG_H__
  26.  
  27. /*(( "Debuglevels" */
  28.  
  29. enum { D_REQUEST,               /* request begin/end, Flags */
  30.     D_IO,                   /* verbose input/output */
  31.     D_CHECK,                /* cache/request checks */
  32.     D_SCAN,                 /* url/request scanning */
  33.     D_QUEUE,                /* queuing process */
  34.     D_MSG,                  /* output log messages */
  35.  
  36.     D_FILES,                /* output cache file names */
  37.     D_CACHE,                /* cache checks debug output */
  38.     D_HASH,                 /* hash value computation / character substitution */
  39.  
  40.     D_NET,                  /* networking debug */
  41.  
  42.     D_ALWAYS                /* first free Debugbit */
  43. } ;
  44.  
  45. #ifdef DEBUG
  46. #  define DEBUG_LEVELS \
  47.            "  1:req  request begin/end, Flags    2:i/o  verbose input/output\n"          \
  48.            "  4:chk  cache/request checks        8:scn  url/request scanning\n"          \
  49.            " 16:que  queuing process            32:msg  output log messages\n"           \
  50.            " 64:fil  output cache file names   128:cch  cache checks\n"                  \
  51.            "256:has  hash value computation / character substitution\n"                  \
  52.            "512:net  network module          (1024:***) always (not to be specified)\n"
  53. #else
  54. #  define DEBUG_LEVELS "Debugging not enabled."
  55. #endif
  56.  
  57. /*)) */
  58. /*(( "Global Variables" */
  59.  
  60. #ifdef DEBUG
  61. /* ok, that string is defined multiple times but how cares... */
  62. static const char * DebugNames [] = {  "req", "i/o", "chk", "scn", "que", "msg", "fil", "cch", "has", "net", "***" };
  63.  
  64. extern int DebugLevel;
  65. static int DebugReturnValue;    /* needed for dreturn */
  66. #endif
  67.  
  68. /*)) */
  69. /*(( "debug() Macros" */
  70.  
  71. #ifdef DEBUG
  72. #  define debug(d,x)       do { if (DebugLevel & (1<<(d))) { printf ("(%s-%12.12s)  ", DebugNames [d], __FUNC__); printf x; } } while (0)
  73. #  define debugraw(d,x)    do { if (DebugLevel & (1<<(d))) printf x; } while (0)
  74. #  define vdebug(d,x,y)    do { if (DebugLevel & (1<<(d))) { printf ("(%s-%12.12s)  ", DebugNames [d], __FUNC__); vprintf (x, y); } } while (0)
  75. #  define vdebugraw(d,x,y) do { if (DebugLevel & (1<<(d))) vprintf (x, y); } while (0)
  76. #  define dreturn(d,x)     return ( DebugReturnValue = (x), ((DebugLevel & (1<<(d))) ? printf ("(%s-%12.12s)  return line %4d --- %d\n", DebugNames [d], __FUNC__, __LINE__, DebugReturnValue) : 0), DebugReturnValue)
  77. #else
  78. #  define debug(d,x)       ((void) 0)
  79. #  define debugraw(d,x)    ((void) 0)
  80. #  define vdebug(d,x,y)    ((void) 0)
  81. #  define vdebugraw(d,x,y) ((void) 0)
  82. #  define dreturn(d,x)     return (x)
  83. #endif
  84.  
  85. /*)) */
  86. /*(( assert()  */
  87.  
  88. /* own assert() writing assertation to logfile */
  89. #ifndef NDEBUG
  90. void ASSERT (int, const char *, const char *, const char *, int);
  91. #  define assert(x)  ASSERT ((int)(x), #x, __FILE__, __FUNC__, __LINE__)
  92. #else
  93. #  define assert(x)  ((void) 0)
  94. #endif
  95.  
  96. /*)) */
  97.  
  98. #endif /* _DEBUG_H__ */
  99.